import { createRouter, createWebHistory } from "vue-router";

const routes = [
  {
    path: "/",
    component: () => import("@/components/user/Login.vue"),
  },
  {
    path: "/main",
    component: () => import("@/components/main/main.vue"),
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

// // 挂载路由导航守卫
// router.beforeEach((to, from, next) => {
//   if (to.meta.title) {
//     document.title = to.meta.title;
//   }
//   if (to.path == "/") return next(); // 访问路径为登录
//   // 获取flag
//   const flagStr = window.sessionStorage.getItem("ID"); // session取值
//   if (!flagStr) return next("login"); // 没登录去登录
//   next();
// });

export default router;
